﻿Imports DTO

Public Class BaoCaoTonDAO
    Public Sub Them(ByVal bctDTO As BaoCaoTonDTO)
        Try
            Dim db As New QuanLyNhaSachDataContext
            Dim bct As New BaoCaoTon
            bct.MaSach = bctDTO.MaSach
            bct.Thang = bctDTO.Thang
            bct.Nam = bctDTO.Nam
            bct.TonDau = bctDTO.TonDau
            bct.PhatSinh = bctDTO.PhatSinh
            bct.TonCuoi = bctDTO.TonDau

            db.BaoCaoTons.InsertOnSubmit(bct)
            db.SubmitChanges()
        Catch ex As Exception
        End Try
        
    End Sub

    Public Function TimKiem_TheoThangNam(ByVal thang As Integer, ByVal nam As Integer) As IQueryable(Of Object)
        Dim db As New QuanLyNhaSachDataContext
        Dim bcts = (From p In db.BaoCaoTons _
                   Where p.Thang = thang And p.Nam = nam _
                   Select New With {p.Sach, p.TonDau, p.PhatSinh, p.TonCuoi})
        Return bcts
    End Function
End Class
